import React, { Component } from 'react'
import axios from 'axios';
import { Tabs } from 'antd-mobile';
import House from '../components/House_c';
import 'antd-mobile/dist/antd-mobile.css'


const tabs = [
    { title: '新房' },
    { title: '二手' },
    { title: '出租' },
];

export default class MakePage extends Component {
    constructor(props) {
        super(props)
        this.state = {
            list: []
        }
        this.handleClick = this.handleClick.bind(this)
    }
    handleClick(id){
        console.log(id);
        // this.state.list.map(v=>{
        //     console.log(v.id);
        //     this.props.history.push('/service?' + v.id + ':李四')
        // })
        this.props.history.push('/service?' + id + ':客服')
    }
    async componentDidMount() {
        const res = await axios({
            method: 'post',
            url: 'https://www.fastmock.site/mock/4f9e05834a115a434e504d41a1dbb3d9/mork/mork/make'
        })
        this.setState({
            list: res.data.data.list
        })
    }
    render() {
        return (
            <>
                <Tabs tabs={tabs} initialPage={0} animated={false} useOnPan={false}>
                    <div>
                        <House onClick={this.handleClick} list={this.state.list}></House>
                    </div>
                    <div>
                        <div>2</div>
                        <House onClick={this.handleClick} list={this.state.list}></House>
                    </div>
                    <div>
                        <div>3</div>
                        <House onClick={this.handleClick} list={this.state.list}></House>
                    </div>
                </Tabs>
            </>
        )
    }
}
